/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Core;

import model.Department;
import model.Employee;
import org.hibernate.Session;
import org.hibernate.Transaction;
import util.IsisHibernateUtil;

/**
 *
 * @author phinguyen
 */
public class StepOwnerCore {

    /**
     * store the hibernate session for the step owner core
     */
    private static Session session;

    public StepOwnerCore() {
        session = IsisHibernateUtil.getSessionFactory().openSession();
    }

    public void addEmployee(Department department, String name, String firstname, String email, String pwd) {
        Employee employee = new Employee(department, name, firstname, email, pwd);
        Transaction tr = session.beginTransaction();
        session.saveOrUpdate(employee);
        tr.commit();
    }

    /**
     * move an employee from a department to an other
     * @param department
     * @param employee 
     */
    public void moveEmployee(Department department, Employee employee){
        employee.setDepartment(department);
    }
}
